package Text.Text1;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

/*
 *@Student 张策
 */
public class text3 {
    public static void main(String[] args) {
        text3 text3 = new text3();
        text3.io();
    }
    public void io(){
        int coad;
        int readlend;
        String name="e:\\hello.txt";
        byte[]buf=new byte[8];
        FileInputStream fileInputStream=null;
        try {
             fileInputStream = new FileInputStream(name);
//            while ((coad=fileInputStream.read())!=-1){//当读取到-1时说明已经读取结束
//                System.out.println((char)coad);
//            }
            while ((readlend=fileInputStream.read(buf))!=-1){//当读取到-1时说明已经读取结束
                System.out.println(readlend);
                System.out.println(new String(buf,0,readlend));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                fileInputStream.close();//关闭
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
